define(['angular', 'router', 'utils/async'], function(angular, router, async) {
    var app = angular.module("webapp", ['ui.router'])
    app.config(function($controllerProvider, $compileProvider, $filterProvider, $provide) {
        app.register = {
            //得到$controllerProvider的引用
            controller: $controllerProvider.register,
            //同样的，这里也可以保存directive／filter／service的引用
            directive: $compileProvider.directive,
            filter: $filterProvider.register,
            service: $provide.service
        };
    });
    app.config(function($stateProvider, $urlRouterProvider) {
        $urlRouterProvider.otherwise('/home');

        $stateProvider
            .state('home', {
                url: '/home',
                templateUrl: 'tpls/home.html'
            })
            // home.list符合惯例
            .state('home.list', {
                url: '/list',
                templateUrl: 'tpls/home-list.html',
                controller: function($scope) {
                    $scope.dogs = ['左拉', '颜值', '傻仔'];
                }
            })
            // home.paragraph符合惯例
            .state('home.paragraph', {
                url: '/paragraph',
                template: '<p>我家还有一只猫，叫小爪</p>'
            })
            .state('about', {
                url: '/about',
                views: {
                    '': {
                        templateUrl: 'tpls/about.html'
                    },

                    // 名称为columnOne的ng-view,viewName@stateName
                    'columnOne@about': {
                        template: '<p>简单显示一段话</p>'
                    },

                    // 名称为columnTow的ng-view,viewName@stateName
                    'columnTwo@about': {
                        templateUrl: 'tpls/data.html',
                        controller: 'SecondController'
                    }
                }

            });
    });

    app.controller('SecondController', function($scope) {

        $scope.message = 'test';

        $scope.products = [{
            name: '概率论与数理统计',
            price: 50
        }, {
            name: 'DELL服务器',
            price: 10000
        }, {
            name: 'Macbook Pro 2016',
            price: 20000
        }];

    });


    return app;
})
